﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using ADONETDataServicesExtension.Utils;
using System.Reflection;

namespace ADONETDataServicesExtension
{
    public class ErrorHandler
    {
        internal const string FrameworkTypeName = "System.Data.Services.ErrorHandler";

        public static Action<Stream> HandleBeforeWritingException(Exception exception, IDataService service, string accept, string acceptCharset)
        {
            return ReflectionHelper.InvokeStaticMethod<Action<Stream>>(FrameworkTypeName, "HandleBeforeWritingException", exception, service.FrameworkObject, accept, acceptCharset);
        }

        public static void HandleTargetInvocationException(TargetInvocationException exception)
        {
            ReflectionHelper.InvokeStaticVoidMethod(FrameworkTypeName, "HandleTargetInvocationException", exception);
        }
    }
}
